package com.scau.ums.model;

/**
 * author: 莫伟杰
 * date： 2019/7/19 9:12
 */
public abstract class User {
    //用户类型
    public static final int ADMIN = 1;
    public static final int STUDENT = 2;
    public static final int TEACHER = 3;
    public static final int MAINTAINER = 4;

    //根据中文返回维修员组别Integer类型
    public static Integer getMaintainerGroupByZhName(String groupName)  {
        if(groupName.equals("维修主管组")){
            return 0;
        }
        else if(groupName.equals("电维修组")){
            return 1;
        }
        else if(groupName.equals("水维修组")){
            return 2;
        }
        else if(groupName.equals("网络维修组")){
            return 3;
        }
        else if(groupName.equals("家具维修组")){
            return 4;
        }
        else return 0;

    }

    //根据中文返回维修员职位Integer类型
    public static Integer getMaintainerRoleByZhName(String roleName)  {
        if(roleName.equals("维修部负责人")){
            return 1;
        }
        else if(roleName.equals("维修组组长")){
            return 2;
        }
        else if(roleName.equals("维修人员")){
            return 3;
        }
        else return 3;

    }

    public abstract String getId();

    public abstract String getName();

    public abstract String getPassword();

    public abstract String getTelephone();

    public abstract String getMail();

    public abstract void setPassword(String password);

    public abstract void setTelephone(String telephone);

    public abstract void setMail(String mail);
    //获取用户类型
    public int getUserType()
    {
        if(this instanceof Admin) return ADMIN;
        if(this instanceof Student) return STUDENT;
        if(this instanceof Teacher) return TEACHER;
        if(this instanceof Maintainer) return MAINTAINER;
        return -1;
    }

    public static int getUserTypeByChinese(String type)
    {
        switch (type)
        {
            case "管理员":return ADMIN;
            case "学生":return STUDENT;
            case "老师":return TEACHER;
            case "维修工":return MAINTAINER;
            default:return -1;
        }
    }

    public static String userTypeToChinese(int userType)
    {
        switch (userType)
        {
            case ADMIN:return "管理员";
            case STUDENT:return "学生";
            case TEACHER:return "老师";
            case MAINTAINER:return "维修工";
            default:return "unknown";
        }
    }
}
